package cn.iocoder.yudao.module.ai.dal.mysql.trainingmodel;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ai.dal.dataobject.trainingmodel.TrainingModelDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ai.controller.admin.trainingmodel.vo.*;

/**
 * 训练模型清单 Mapper
 *
 * @author gt
 */
@Mapper
public interface TrainingModelMapper extends BaseMapperX<TrainingModelDO> {

    /**
     * 分页查询不包含草稿的模型
     * @param reqVO
     * @return
     */
    default PageResult<TrainingModelDO> selectPageNotDraft(TrainingModelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TrainingModelDO>()
                .likeIfPresent(TrainingModelDO::getModelName, reqVO.getModelName())
                .eqIfPresent(TrainingModelDO::getModelDesc, reqVO.getModelDesc())
                .eqIfPresent(TrainingModelDO::getModelPath, reqVO.getModelPath())
                .eqIfPresent(TrainingModelDO::getModelType, reqVO.getModelType())
                .eqIfPresent(TrainingModelDO::getHardware, reqVO.getHardware())
                .eqIfPresent(TrainingModelDO::getTrainCmd, reqVO.getTrainCmd())
                .eqIfPresent(TrainingModelDO::getTestCmd, reqVO.getTestCmd())
                .eqIfPresent(TrainingModelDO::getSuplierId, reqVO.getSuplierId())
                .eqIfPresent(TrainingModelDO::getCreator, reqVO.getCreator())
                .ne(TrainingModelDO::getStatus,"0")
                .betweenIfPresent(TrainingModelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TrainingModelDO::getId));
    }

    default PageResult<TrainingModelDO> selectPage(TrainingModelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TrainingModelDO>()
                .likeIfPresent(TrainingModelDO::getModelName, reqVO.getModelName())
                .eqIfPresent(TrainingModelDO::getModelDesc, reqVO.getModelDesc())
                .eqIfPresent(TrainingModelDO::getModelPath, reqVO.getModelPath())
                .eqIfPresent(TrainingModelDO::getModelType, reqVO.getModelType())
                .eqIfPresent(TrainingModelDO::getHardware, reqVO.getHardware())
                .eqIfPresent(TrainingModelDO::getTrainCmd, reqVO.getTrainCmd())
                .eqIfPresent(TrainingModelDO::getTestCmd, reqVO.getTestCmd())
                .eqIfPresent(TrainingModelDO::getSuplierId, reqVO.getSuplierId())
                .eqIfPresent(TrainingModelDO::getCreator, reqVO.getCreator())
                .eqIfPresent(TrainingModelDO::getStatus,reqVO.getStatus())
                .betweenIfPresent(TrainingModelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TrainingModelDO::getId));
    }




}